#include "../includes/OTHER_TYPES/ARRAY/CHAR/CHAR_ARR/CHAR_ARR.h"
#include "../includes/OTHER_TYPES/ARRAY/NUMBER/INT.h"

int main(int argc, char * argv[])
{  
  CHECK_SYS_ENDIAN();
  
  char real[16] = {
    0x00, 0x00, 0x00, 0x57, 0x00, 0x69, 0x00, 0x69, 0x00, 0x20, 0xB9, 0xAC, 0xBA, 0xA8, 0xCE, 0xE8
  };
  
  // default behaviour is ASCII
  printf("Interpret the byte array: ");
  print_array(real, 16, 1, print_byte_hex);
  printf("as encoded in...\n\n");
  printf("(%llu chars)\n", print_chenc_arr(real, 16, CHAR_ENC_ASCII));
  printf("(%llu chars)\n", print_chenc_arr(real, 16, CHAR_ENC_UTF16BE));
  printf("(%llu chars)\n", print_chenc_arr(real, 16, CHAR_ENC_UTF16LE));
  printf("(%llu chars)\n", print_chenc_arr(real, 16, CHAR_ENC_UTF8));
  printf("(%llu chars)\n", print_chenc_arr(real, 16, CHAR_ENC_CP932));
  printf("(%llu chars)\n", print_chenc_arr(real, 16, CHAR_ENC_CP1252));
  printf("(%llu chars)\n", print_chenc_arr(real, 16, CHAR_ENC_SHIFT_JIS));
  
  printf("\nInterpret the byte array: ");
  print_array(real, 16, 1, print_byte_hex);
  printf("as encoded in...\n\n");
  printf("(%llu chars)\n", print_chenc_arr_as_unicd(real, 16, CHAR_ENC_ASCII));
  printf("(%llu chars)\n", print_chenc_arr_as_unicd(real, 16, CHAR_ENC_UTF16BE));
  printf("(%llu chars)\n", print_chenc_arr_as_unicd(real, 16, CHAR_ENC_UTF16LE));
  printf("(%llu chars)\n", print_chenc_arr_as_unicd(real, 16, CHAR_ENC_UTF8));
  printf("(%llu chars)\n", print_chenc_arr_as_unicd(real, 16, CHAR_ENC_CP932));
  printf("(%llu chars)\n", print_chenc_arr_as_unicd(real, 16, CHAR_ENC_CP1252));
  printf("(%llu chars)\n", print_chenc_arr_as_unicd(real, 16, CHAR_ENC_SHIFT_JIS));

  putchar('\n');  
  umax chint = 0x20;
  printf("%d\n", (char *) find_chint_in_chenc_arr(real, 16, CHAR_ENC_UTF16BE, &chint) - &real[0]);
  printf("%d\n", (char *) find_chint_in_chenc_arr(real, 16, CHAR_ENC_UTF16LE, &chint) - &real[0]);
  chint = 0xBAA8;
  printf("%d\n", (char *) find_chint_in_chenc_arr(real, 16, CHAR_ENC_UTF16BE, &chint) - &real[0]);
  printf("%d\n", (char *) find_chint_in_chenc_arr(real, 16, CHAR_ENC_UTF16LE, &chint) - &real[0]);
  

  return 0;
}
